package com.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.constant.MessageConstant;
import com.entity.PageResult;
import com.entity.QueryPageBean;
import com.entity.Result;
import com.pojo.CheckItem;
import com.service.CheckItemService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/CheckItem")
public class CheckItemController {
    @Reference
    private CheckItemService checkItemService;
    //查询所有
    @RequestMapping("/findAllCheckTtem")
    public Result findAllCheckTtem(){
        List<CheckItem> allCheckTtem = checkItemService.findAllCheckTtem();
        Result result = new Result(true, "查询成功", allCheckTtem);
        return result;
    };
    //插入检查项
    @RequestMapping("/insertCheckTtem")
    public Result insertCheckTtem(@RequestBody CheckItem checkItem){
        /*CheckItem c = new CheckItem();
        c.setId(null);
        c.setCode("哈");
        c.setName("好");
        c.setSex("你");
        int i = checkItemService.insertCheckTtem(c);
        System.out.println(i);*/
        Result result = checkItemService.insertCheckTtem(checkItem);
       return result;
    }
    //分页查询
    @RequestMapping("/findByProjectNameAndCode")
    public PageResult findByPage(@RequestBody QueryPageBean queryPageBean){
        PageResult byPage = checkItemService.findByPage(queryPageBean);
        //System.out.println(byPage);
        return byPage;
    }
    //删除检查项
    @RequestMapping("/deleteCheckItem")
    public Result deleteCheckItem(int id){
        Result result = checkItemService.deleteCheckItem(id);
        return result;
    }
    //动态修改检查项数据数据
    @RequestMapping("/updateCheckItem")
    public Result updateCheckItem(@RequestBody CheckItem checkItem){
        Result result = checkItemService.updateCheckItem(checkItem);
        return result;
    }
}
